<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <br/>
            <h3 class="title">Visualizando Imóvel</h3>

            <h:form id="realtyForm" enctype="multipart/form-data">
                <p:growl id="messages" showDetail="true" autoUpdate="true"  />
                <p:panel id="realtyPanel" style="background: none; border: none;" 
                         styleClass="container_24 clearfix ">
                    <h4 class="title">Dados Gerais</h4>

                    <p:outputLabel value="Nº da Ordem:" styleClass="grid_3" for="numOrderInputText"/>
                    <p:inputText id="numOrderInputText" styleClass="grid_8"
                                 readonly="true" value="#{managerSearchRealty.realty.numOrder}"/>

                    <p:outputLabel value="Título:" styleClass="grid_4 alpha" for="titleInputText" />
                    <p:inputText id="titleInputText" styleClass="grid_8"
                                 readonly="true" value="#{managerSearchRealty.realty.title_notary}" />

                    <p:outputLabel value="Data do Cadastro:" styleClass="grid_3 createDateLabel" 
                                   for="dateCreateCalendar" />
                    <p:inputText id="dateCreateCalendar" styleClass="grid_8"
                                 readonly="true" value="#{managerSearchRealty.realty.date_create}">
                        <f:convertDateTime pattern="dd/MM/yyyy" />
                    </p:inputText>

                    <p:outputLabel value="Tipo do Imóvel:" styleClass="grid_4 alpha" 
                                   for="typeRealtySelectOneMenu"/>
                    <p:inputText id="typeRealtySelectOneMenu" styleClass="grid_8"
                                 readonly="true" value="#{managerSearchRealty.realty.typeRealty}" />  

                    <p:outputLabel value="Registro Anterior:" styleClass="grid_3 createDateLabel" 
                                   for="previousRecordInputText"/>
                    <p:inputText id="previousRecordInputText" styleClass="grid_8" 
                                 readonly="true" value="#{managerSearchRealty.realty.previous_record}"/>
                </p:panel>

                <p:panel id="tenurePanel" style="background: none; border: none;" 
                         styleClass="container_24 clearfix ">
                    <h4 class="title">Aforamento</h4>

                    <p:outputLabel value="Nº Aforamento:" styleClass="grid_3 createDateLabel" 
                                   for="num_tenureInputText"/>
                    <p:inputText id="num_tenureInputText" styleClass="grid_8" 
                                 readonly="true" value="#{managerSearchRealty.realty.num_tenure}"/>

                    <p:outputLabel value="Data Aforamento:" styleClass="grid_4 alpha" 
                                   for="dateTenureCalendar"/>
                    <p:inputText id="dateTenureCalendar" styleClass="grid_8"
                                 readonly="true" value="#{managerSearchRealty.realty.date_tenure}">
                        <f:convertDateTime pattern="dd/MM/yyyy" />
                    </p:inputText>
                </p:panel>

                <p:panel id="bookPanel" style="background: none; border: none;" 
                         styleClass="container_24 clearfix ">
                    <h4 class="title">Livro</h4>
                    
                    <p:outputLabel value="Livro:" styleClass="grid_3" for="bookInputText" />
                    <p:inputText id="bookInputText" styleClass="grid_8" 
                                 readonly="true" value="#{managerSearchRealty.realty.book}" />

                    <p:outputLabel value="Complemento:" styleClass="grid_4 alpha" 
                                   for="complementBookInputText" />
                    <p:inputText id="complementBookInputText" styleClass="grid_8" 
                                 readonly="true" value="#{managerSearchRealty.realty.complementBook}" />

                    <p:outputLabel value="Folha:" styleClass="grid_3" for="leafInputText" />
                    <p:inputText id="leafInputText" styleClass="grid_8" 
                                 readonly="true" value="#{managerSearchRealty.realty.leaf}" />

                    <p:outputLabel value="Complemento:" styleClass="grid_4 alpha" 
                                   for="complementLeafInputText" />
                    <p:inputText id="complementLeafInputText" styleClass="grid_8"
                                 readonly="true" value="#{managerSearchRealty.realty.complementLeaf}" />
                </p:panel>

                <p:panel id="bookNotaryPanel" style="background: none; border: none;" 
                         styleClass="container_24 clearfix ">
                    <h4 class="title">Cartório</h4>
                    
                    <p:outputLabel value="Livro:" styleClass="grid_3" for="bookNotaryInputText" />
                    <p:inputText id="bookNotaryInputText" styleClass="grid_3" 
                                 readonly="true" value="#{managerSearchRealty.realty.book_notary}" />

                    <p:outputLabel value="Cartótio Lavrado:" styleClass="grid_4 alpha" 
                                   for="notaryPlowedInputText" />
                    <p:inputText id="notaryPlowedInputText" styleClass="grid_13" 
                                 readonly="true" value="#{managerSearchRealty.realty.notary_plowed}" />

                    <p:outputLabel value="Folha:" styleClass="grid_3" for="leafNotaryInputText" />
                    <p:inputText id="leafNotaryInputText" styleClass="grid_3" 
                                 readonly="true" value="#{managerSearchRealty.realty.leaf_notary}" />

                    <p:outputLabel value="Título:" styleClass="grid_4 alpha" for="titleNotaryInputText" />
                    <p:inputText id="titleNotaryInputText" styleClass="grid_13"
                                 readonly="true" value="#{managerSearchRealty.realty.title_notary}" />
                </p:panel>

                <p:panel id="ownersPanel" style="background: none; border: none"
                         styleClass="container_24 clearfix">
                    <h4 class="title">Proprietátios</h4>

                    <p:dataTable id="ownersDataTable" var="item" value="#{managerSearchRealty.realty.proprietarios}" 
                                 styleClass="grid_24" rowIndexVar="rowid" emptyMessage="Nenhum registro">  
                        <f:facet name="header">
                            Proprietário
                        </f:facet>
                        <p:column headerText="Nome / Razão Social" width="70%">  
                            <h:outputText value="#{item.tipoDocumento.tipo eq 'CPF' ? item.nome : item.nomeFantasia}"/>
                        </p:column>  
                        <p:column headerText="CPF / CNPJ" style="text-align: center">
                            <h:outputText value="#{item.tipoDocumento.tipo eq 'CPF' ? item.cpf : item.cnpj}" />
                        </p:column>

                    </p:dataTable> 

                </p:panel>

                <br/>

                <p:panel id="addressPanel" style="background: none; border: none;" 
                         styleClass="container_24 clearfix ">
                    <h4 class="title">Endereço</h4>

                    <p:outputLabel value="CEP:" styleClass="grid_3" for="cepInputMask" />
                    <p:inputMask id="cepInputMask" styleClass="grid_8" mask="99.999-999"
                                 readonly="true" value="#{managerSearchRealty.endereco.cep}" />
                    <div class="clear-both" />

                    <p:outputLabel value="Logradouro:" styleClass="grid_3" for="patioInputText" />
                    <p:inputText id="patioInputText" styleClass="grid_20" readonly="true" 
                                 value="#{managerSearchRealty.endereco.logradouro}" />

                    <p:outputLabel value="Bairro:" styleClass="grid_3" for="neighborhoodInputText" />
                    <p:inputText id="neighborhoodInputText" styleClass="grid_20" readonly="true" 
                                 value="#{managerSearchRealty.endereco.bairro}" />

                    <p:outputLabel value="Nº:" styleClass="grid_3" for="numInputText" />
                    <p:inputText id="numInputText" styleClass="grid_8" readonly="true" 
                                 value="#{managerSearchRealty.endereco.numero}" />

                </p:panel>

                <p:panel id="identificationPanel" style="background: none; border: none;" 
                         styleClass="container_24 clearfix ">
                    <h4 class="title">Dimensões e Confrontações</h4>

                    <h5 class="title">Frente</h5>
                    <p:outputLabel value="Para:" styleClass="grid_3" for="frenteInputText" />
                    <p:inputText id="frenteInputText" styleClass="grid_10"
                                 value="#{managerSearchRealty.imovel.frente}" />
                    <div class="clear"/>
                    <p:outputLabel value="Rua:" styleClass="grid_3" for="frenteRuaInputText" />
                    <p:inputText id="frenteRuaInputText" styleClass="grid_10"
                                 value="#{managerSearchRealty.imovel.frenteRua}" />
                    <div class="clear"/>
                    <p:outputLabel value="Medindo:" styleClass="grid_3" for="frenteMedInputText" />
                    <p:inputText id="frenteMedInputText" styleClass="grid_10"
                                 value="#{managerSearchRealty.imovel.frenteMedindo}" />
                    <div class="clear"/>
                    <h5 class="title">Lado Direito</h5>

                    <p:outputLabel value="Para:" styleClass="grid_3" for="direitoParaInputText" />
                    <p:inputText id="direitoParaInputText" styleClass="grid_18" 
                                 value="#{managerSearchRealty.imovel.ladoDireito}" />
                    <div class="clear"/>

                    <p:outputLabel value="Rua:" styleClass="grid_3" for="direitoRuaInputText" />
                    <p:inputText id="direitoRuaInputText" styleClass="grid_18" 
                                 value="#{managerSearchRealty.imovel.ladoDireitoRua}" />
                    <div class="clear"/>

                    <p:outputLabel value="Medindo:" styleClass="grid_3" for="direitoMedInputText" />
                    <p:inputText id="direitoMedInputText" styleClass="grid_18" 
                                 value="#{managerSearchRealty.imovel.ladoDireitoMedindo}" />
                    <div class="clear"/>
                    <h5 class="title">Lado Esquerdo</h5>
                    <p:outputLabel value="Para:" styleClass="grid_3" for="esquerdoInputText" />
                    <p:inputText id="esquerdoInputText" styleClass="grid_18" 
                                 value="#{managerSearchRealty.imovel.ladoEsquerdo}" />
                    <div class="clear"/>

                    <p:outputLabel value="Rua:" styleClass="grid_3" for="esquerdoRuaInputText" />
                    <p:inputText id="esquerdoRuaInputText" styleClass="grid_18" 
                                 value="#{managerSearchRealty.imovel.ladoEsquerdoRua}" />
                    <div class="clear"/>

                    <p:outputLabel value="Medindo:" styleClass="grid_3" for="esquerdoMedInputText" />
                    <p:inputText id="esquerdoMedInputText" styleClass="grid_18" 
                                 value="#{managerSearchRealty.imovel.ladoEsquerdoMedindo}" />
                    <div class="clear"/>

                    <h5 class="title">Fundo</h5>


                    <p:outputLabel value="Para:" styleClass="grid_3" for="fundoInputText" />
                    <p:inputText id="fundoInputText" styleClass="grid_18" 
                                 value="#{managerSearchRealty.imovel.fundo}" />
                    <div class="clear"/>
                    <p:outputLabel value="Rua:" styleClass="grid_3" for="fundoRuaInputText" />
                    <p:inputText id="fundoRuaInputText" styleClass="grid_18" 
                                 value="#{managerSearchRealty.imovel.fundoRua}" />
                    <div class="clear"/>
                    <p:outputLabel value="Medindo:" styleClass="grid_3" for="fundoMedInputText" />
                    <p:inputText id="fundoMedInputText" styleClass="grid_18" 
                                 value="#{managerSearchRealty.imovel.fundoMedindo}" />

                    <div class="clear"/>
                    <br/>

                    <h5 class="title">Dimensões Terreno</h5>
                    <br/>
                    <p:outputLabel value="Área Terreno:" styleClass="grid_3" for="areaInputText" />
                    <p:inputText id="areaInputText" styleClass="grid_4" 
                                 value="#{managerSearchRealty.imovel.dimensoes.areaTerreno}"
                                 onkeypress="jQuery(this).autoNumeric({aSep: '.', aDec: ','} );">
                        <f:convertNumber pattern="#,###,##0.00"/>
                        <!--                                    <p:ajax event="change" update="areaTerrenoTaxaInputText" />-->
                    </p:inputText>

                    <div class="clear"/>
                    <p:outputLabel value="Área Unidade:" styleClass="grid_3" for="areaUInputText" />
                    <p:inputText id="areaUInputText" styleClass="grid_4"
                                 value="#{managerSearchRealty.imovel.dimensoes.areaUnidade}"
                                 onkeypress="jQuery(this).autoNumeric({aSep: '.', aDec: ','} );">
                        <f:convertNumber pattern="#,###,##0.00"/>
                        <!--<p:ajax event="change" update="areaUnidadeTaxaInputText" />-->
                    </p:inputText>

                    <div class="clear"/>
                    <p:outputLabel value="Área Total:" styleClass="grid_3" for="areaTInputText" />
                    <p:inputText id="areaTInputText" styleClass="grid_4"
                                 value="#{managerSearchRealty.imovel.dimensoes.areaTotalEdificacao}"
                                 onkeypress="jQuery(this).autoNumeric({aSep: '.', aDec: ','} );">
                        <f:convertNumber pattern="#,###,##0.00"/>
                        <!--<p:ajax event="change" update="areaTotalTaxaInputText" />-->
                    </p:inputText>

                    <div class="clear"/>
                    <p:outputLabel value="N˚Pavimento:" styleClass="grid_3" for="areaPInputText" />
                    <p:inputText id="areaPInputText" styleClass="grid_2"
                                 value="#{managerSearchRealty.imovel.dimensoes.numPavimentacaoEdific}">
                        <!--<p:ajax event="change" update="nPavimentoInputText" />-->
                    </p:inputText>
                    <div class="clear"/>
                    <br/>

                    <div class="clear"/>
                    <h5 class="title">Testada</h5>
                    <br/>
                    <p:outputLabel value="Testada do Imóvel:" style="width: 20%" styleClass="grid_3" for="areaTiInputText" />
                    <p:inputText id="areaTiInputText" styleClass="grid_4"
                                 value="#{managerSearchRealty.imovel.dimensoes.testadaImovel}"
                                 onkeypress="jQuery(this).autoNumeric({aSep: '.', aDec: ','} );">
                        <f:convertNumber pattern="#,###,##0.00"/>
                    </p:inputText>

                    <p:outputLabel value="Servida Conservação Calçamento:" style="width: 30%" styleClass="grid_3" for="areaTSInputText" />
                    <p:inputText id="areaTSInputText" styleClass="grid_4"
                                 value="#{managerSearchRealty.imovel.dimensoes.testadaServidaConservCalcamento}"
                                 onkeypress="jQuery(this).autoNumeric({aSep: '.', aDec: ','} );">
                        <f:convertNumber pattern="#,###,##0.00"/>
                    </p:inputText>

                    <div class="clear"/>
                    <p:outputLabel value="Servida Iluminação Publica:" style="width: 20%" styleClass="grid_3" for="areaTIInputText" />
                    <p:inputText id="areaTIInputText" styleClass="grid_4"
                                 value="#{managerSearchRealty.imovel.dimensoes.testadaServidaPorIluminacaoPublica}"
                                 onkeypress="jQuery(this).autoNumeric({aSep: '.', aDec: ','} );">
                        <f:convertNumber pattern="#,###,##0.00"/>
                    </p:inputText>

                    <p:outputLabel value="Servida Limpeza Publica:" style="width: 30%" styleClass="grid_3" for="areaTLInputText" />
                    <p:inputText id="areaTLInputText" styleClass="grid_4"
                                 value="#{managerSearchRealty.imovel.dimensoes.testadaServidaLimpezaPublica}"
                                 onkeypress="jQuery(this).autoNumeric({aSep: '.', aDec: ','} );">
                        <f:convertNumber pattern="#,###,##0.00"/>
                    </p:inputText>
                </p:panel>
                
                <br/>
                
                <p:panel id="annexPanel" style="background: none; border: none;"
                         styleClass="container_24 clearfix" >
                    <h4 class="title">Anexos</h4>

                    <p:dataGrid id="tableAnnex" var="a" value="#{managerSearchRealty.annexs}" 
                                rowIndexVar="rowid"
                                paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                rows="6" paginator="true"  
                                paginatorPosition="bottom"
                                emptyMessage="Nenhum registro">  

                        <p:panel header="Doc Digital" style="text-align:center; width: 280px;">  

                            <h:outputLink  
                                value="#{a.type ne 'application/pdf' ? 'viewImage.xhtml':'show'}" title="#{a.description}"  target="_blank" >

                                <div style="text-align: center; width: 20%;" class="grid_4">

                                    <p:graphicImage styleClass="image grid_3" rendered="#{a.type ne 'application/pdf'}"
                                                    style="margin-left:1%; width: 50px;"
                                                    url="show/?annex=#{a.id}" />

                                    <p:outputLabel  value="#{a.description.length() ge 10 ? a.description.substring(0, 10).concat('...') : 
                                                             a.description.replace('.png','').replace(' ','_')}" 
                                                    style="margin-left:1%; width: 100px;" rendered="#{a.type ne 'application/pdf'}"/>

                                    <p:graphicImage styleClass="image grid_3" rendered="#{a.type eq 'application/pdf'}"
                                                    style="margin-left:1%; width: 100px;" 
                                                    url="assets/images/pdf.jpeg" />


                                    <p:outputLabel  value="#{a.description.length() ge 10 ? a.description.substring(0, 10).concat('...') : 
                                                             a.description.replace('.pdf','').replace(' ','_')}" 
                                                    style="margin-left:1%; width: 100px;" rendered="#{a.type eq 'application/pdf'}"/>

                                </div>
                                <f:param name="annex" value="#{a.id}"/>
                            </h:outputLink>
                            <div class="clear"/>

                        </p:panel>  

                    </p:dataGrid>
                </p:panel>

                <br />
                <div class="buttonAction">
                    <p:button href="pesquisaraforamento.xhtml" value="Voltar"  icon="ui-icon-arrowreturnthick-1-w" />
                </div >
            </h:form>

        </ui:define>
    </ui:composition>

</html>
